package com.anli.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/8/30  15:33
 * 描述:
 */
//@Configuration
public class TestRedisRedLock {

    @Bean("redissonClient1")
    @Primary
    public RedissonClient getRedissionClient1(){

        Config config=new Config();
        //集群
        //config.useClusterServers().addNodeAddress("redis://127.0.0.1:6379","redis://127.0.0.1:6379","redis://127.0.0.1:6379").setPassword("");

        //单节点
        config.useSingleServer().setAddress("redis://127.0.0.1:6379").setPassword("123456").setDatabase(0);
        RedissonClient redissonClient = Redisson.create(config);

        return redissonClient;

    }

    @Bean("redissonClient2")
    public RedissonClient getRedissionClient2(){
        Config config=new Config();
        //集群
        //config.useClusterServers().addNodeAddress("redis://127.0.0.1:6379","redis://127.0.0.1:6379","redis://127.0.0.1:6379").setPassword("");

        //单节点
        config.useSingleServer().setAddress("redis://127.0.0.1:6379").setPassword("123456").setDatabase(0);
        RedissonClient redissonClient = Redisson.create(config);

        return redissonClient;
    }

    @Bean("redissonClient3")
    public RedissonClient getRedissionClient3(){
        Config config=new Config();
        //集群
        //config.useClusterServers().addNodeAddress("redis://127.0.0.1:6379","redis://127.0.0.1:6379","redis://127.0.0.1:6379").setPassword("");

        //单节点
        config.useSingleServer().setAddress("redis://127.0.0.1:6379").setPassword("123456").setDatabase(0);
        RedissonClient redissonClient = Redisson.create(config);

        return redissonClient;
    }

}
